package com.atguigu.srb.core.controller.admin;


import com.atguigu.common.result.R;
import com.atguigu.srb.core.pojo.entity.BorrowInfo;
import com.atguigu.srb.core.pojo.vo.BorrowInfoApprovalVO;
import com.atguigu.srb.core.service.BorrowInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 借款信息表 前端控制器
 * </p>
 *
 * @author 杜佳佳
 * @since 2021-04-13
 */
@Api(tags = "借款信息管理")
@RestController
@RequestMapping("/admin/core/borrowInfo")
public class AdminBorrowInfoController {

    @Autowired
    private BorrowInfoService borrowInfoService;

    @ApiOperation("全部借款信息列表")
    @GetMapping("/allList")
    public R allList() {
        List<BorrowInfo> list = borrowInfoService.selectListAll();
        return R.ok().data("list",list);
    }

    @ApiOperation("根据id获取借款信息详情")
    @GetMapping("/info/{id}")
    public R info(@PathVariable Long id) {

        Map<String,Object> map = borrowInfoService.getBorrowInfoDetail(id);
        return R.ok().data("borrowInfoDetail",map);
    }

    @ApiOperation("借款申请审批")
    @PostMapping("/approval")
    public R approval(@RequestBody BorrowInfoApprovalVO borrowInfoApprovalVO) {
        borrowInfoService.approval(borrowInfoApprovalVO);
        return R.ok();
    }



}

